package shiyan3.jichu;

import java.util.ArrayList;
import java.util.List;
import shiyan3.ceshi.person;
public class Student extends person {
    private List<Course> selectedCourses = new ArrayList<>();

    public Student(String id, String name, String gender) {
        super(id, name, gender);
    }

    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + "同学选择了课程：" + course.getCourseName());
    }

    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + "同学退选了课程：" + course.getCourseName());
        } else {
            System.out.println(name + "同学未选择该课程，无法退选");
        }
    }

    public void printCourseSchedule() {
        System.out.println(name + "同学的课表：");
        for (Course course : selectedCourses) {
            System.out.println("课程编号：" + course.getCourseId() + "，课程名称：" + course.getCourseName() + "，上课地点：" + course.getLocation() + "，时间：" + course.getTime());
        }
    }

    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }

    public void setSelectedCourses(List<Course> selectedCourses) {
        this.selectedCourses = selectedCourses;
    }
}
